var t = getApp();

Page({
  data: {
    Interval: null,
    showPacket: !1,
    name: "",
    is_cps: "",
    order_id: "",
    order_id_new: '',
  },
  onLoad: function (t) {
    wx.setNavigationBarTitle({
      title: "跳转中"
    }), console.log(t), t.is_cps && this.setData({
      is_cps: t.is_cps
    }), t.name && this.setData({
      name: t.name
    }), t.ids && this.setData({
      order_id: t.ids
    }), t.sn && this.setData({
      order_sn: t.sn
    }), t.order_id_new && this.setData({
      order_id_new: t.order_id_new
    }), this.getData();
  },
  toPacket: function () {
    wx.navigateTo({
      url: "/packageE/ConsumePacket/ConsumePacketSuccess/ConsumePacketSuccess?order_id=" + this.data.order_id.toString()
    });
  },
  onClickHide: function () {
    this.setData({
      showPacket: !1
    }), this.toRedirect(this.data.redirect);
  },
  getData: function () {
    var e = this,
      a = {},
      r = "";
    "tourAround" == this.data.name ? (r = "plugin.travel-around.frontend.payment.payment.checkOrderPay",
      a = {
        order_id: this.data.order_id
      }) : (r = "order.merge-pay.check-order-pay", a = {
      order_pay_id: this.data.order_id
    });
    var n = t.getNetAddresss(r);
    t._postNetWork({
      url: n,
      data: a,
      success: function (a) {
        t._postNetWork({
          url: t.getNetAddresss("Guxinyu.pay_order"),
          data: {
            order_id: e.data.order_id_new,
            uid: wx.getStorageSync("uid") ? wx.getStorageSync("uid") : wx.getStorageSync("yz_uid")
          },
          success: function (t) {
            if (1 == t.data.result) {

              // a.toRedirect(e)
            }
          },
          fail: function (t) {
            // a.toRedirect(e);
          }
        });
        t._postNetWork({
          url: t.getNetAddresss("Guxinyu.web_shengji"),
          data: {
            uid: wx.getStorageSync("uid") ? wx.getStorageSync("uid") : wx.getStorageSync("yz_uid")
          },
          success: function (t) {
            if (1 == t.data.result) {
              // a.toRedirect(e)
            }
          },
          fail: function (t) {
            // a.toRedirect(e);
          }
        });
        var r = a.data;
        1 == r.result ? 1 == r.data.status ? (e.setData({
          redirect: r.data.redirect
        }), e.checkoutConsumePacket(r.data.redirect), clearInterval(e.data.Interval), e.data.Interval = null) : e.data.Interval || (e.data.Interval = setInterval(function () {
          e.getData();
        }, 1e3)) : t.tips(r.msg);
      },
      fail: function (t) {}
    });
  },
  checkoutConsumePacket: function (e) {
    var a = this,
      r = wx.getStorageSync("yz_basic_info");
    if (r && 1 == r.globalParameter.consume_red_packet_status) {
      var n = t.getNetAddresss("plugin.consume-red-packet.Frontend.Modules.Packet.Controllers.has.index");
      t._postNetWork({
        url: n,
        data: {
          order_id: this.data.order_id.split(",")
        },
        success: function (t) {
          1 == t.data.result ? a.setData({
            showPacket: !0
          }) : a.toRedirect(e);
        },
        fail: function (t) {
          a.toRedirect(e);
        }
      });
    } else this.toRedirect(e);
  },
  toRedirect: function (t) {
    console.log(t), this.data.is_cps ? wx.navigateTo({
      url: "/packageA/member/order/cpsCoupon/cpsCoupon"
    }) : "Myshaky" != this.data.name ? this.data.order_sn && this.payCallBack(t) : wx.navigateTo({
      url: "/packageC/Myshaky/activityHome/activityHome"
    });
  },
  payCallBack: function (e) {
    console.log(e);
    var a = "";
    if (1 != t.globalData.store_alone_temp)
      if (t._isTextEmpty(e)) wx.reLaunch({
        url: "/packageG/index/index"
      });
      else try {
        if ("groups" != this.data.name && "ywmGroup" != this.data.name || -1 == e.indexOf("group_detail")) wx.redirectTo({
          url: e,
          fail: function (t) {
            console.log(t), wx.reLaunch({
              url: "/packageG/index/index"
            });
          }
        });
        else {
          var r = e.match(/group_detail\/(\S*)\?i/)[1];
          a = "/packageB/member/group/GroupDetail/GroupDetail?id=" + (r = r.split("/"))[0],
            "ywmGroup" == this.data.name && (a += "&plu=ywm"), r[1] ? wx.redirectTo({
              url: a + "&store_id=" + r[1]
            }) : wx.redirectTo({
              url: a
            });
        }
      } catch (t) {
        wx.reLaunch({
          url: "/packageG/index/index"
        });
      } else wx.reLaunch({
        url: "/packageG/independent_store/index/index?store_id=" + t.globalData.STORE_ID
      });
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {
    clearInterval(this.data.Interval), this.data.Interval = null;
  },
  onUnload: function () {
    clearInterval(this.data.Interval), this.data.Interval = null;
  },
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {}
});